//
//  MainViewController.m
//  HxgProject
//
//  Created by hxg on 2018/3/2.
//  Copyright © 2018年 XMYY-19. All rights reserved.
//

#import "RootTabViewController.h"
#import "RDVTabBarItem.h"

#import "BaseNavigationController.h"

#import "MeViewController.h"
#import "HomeViewController.h"
#import "AuthenViewController.h"

@interface RootTabViewController ()

@end

@implementation RootTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupViewControllers];
}

- (void)setupViewControllers
{
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    UINavigationController *nav_home = [[BaseNavigationController alloc] initWithRootViewController:homeVC];
    
    AuthenViewController *authenVc = [[AuthenViewController alloc] init];
    UINavigationController *nav_auther = [[BaseNavigationController alloc] initWithRootViewController:authenVc];
    
    MeViewController *meVC = [[MeViewController alloc] init];
    UINavigationController *nav_me = [[BaseNavigationController alloc] initWithRootViewController:meVC];
    
    
    [self setViewControllers:@[nav_home, nav_auther, nav_me]];

    [self customizeTabBarForController];

    self.delegate = self;
}

- (void)customizeTabBarForController
{
    NSArray *tabBarItemImages = @[@"edu", @"JK_auther", @"JK_me"];
    NSArray *tabBarItemTitles = @[@"套餐", @"认证", @"我的"];
    NSInteger index = 0;
    for (RDVTabBarItem *item in [[self tabBar] items]) {
        item.titlePositionAdjustment = UIOffsetMake(0, 3);
        UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",
                                                      [tabBarItemImages objectAtIndex:index]]];
        UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",
                                                        [tabBarItemImages objectAtIndex:index]]];
        [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
        [item setTitle:[tabBarItemTitles objectAtIndex:index]];
        item.badgePositionAdjustment = UIOffsetMake(0, kSafeArea_Bottom / 2);
        [item setSelectedTitleAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:@"ea5f35"]}];
        [item setUnselectedTitleAttributes:@{NSForegroundColorAttributeName: fontGrayColor}];
        
        index++;
    }
    [self.tabBar setHeight:49 + kSafeArea_Bottom];
    [self.tabBar setContentEdgeInsets:UIEdgeInsetsMake(kSafeArea_Bottom / 2, 0, 0, 0)];
    self.tabBar.backgroundView.backgroundColor = kColorNavBG;
   // [self.tabBar addLineUp:YES andDown:NO andColor:kColorCCC];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreate
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
